home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
BASIC
/
LIB
/
COMPLEX
< prev
next >
Wrap
Text File
|
1991-07-21
|
9KB
|
270 lines
10REM > %.COMPLEX LIBRARY INCLUDING TRANCEDENTAL FUNCTIONS.
20PROCINITCOMPLEX
30PROCHELP
40END
50REM----------------------------------------------------------------------
60REM > TSTCMPLX
70ON ERROR INSTALL "%.COMPLEX":RUN
80PROCINITCOMPLEX
90ON ERROR OFF
100MODE9
110FORX%=0TO1280STEP4:X=-2+2.5*X%/1280.
120 FORY%=0TO1024STEP4:Y=-1.25+2.5*Y%/1024.
130 PROCSET(0,0,Z())
140 PROCSET(X,Y,C())
150 N%=0
160 REPEAT
170 N%+=1
180 PROCMUL(Z(),Z(),A())
190 PROCADD(A(),C(),Z())
200 UNTIL N%=20 OR FNABS(Z())>2.
210 IF N%=20 GCOL0 ELSE GCOL((N%MOD7)+1)
220 PLOT69,X%,Y%
230 NEXT
240NEXT
250END
260:
270:
280:
290REM > TSTCMPLX2
300ON ERROR INSTALL "%.COMPLEX":RUN
310PROCINITCOMPLEX
320S=1.2
330ON ERROR OFF
340MODE9
350FORX%=0TO1024STEP4:X=-S+2*S*X%/1024.
360 FORY%=0TO1024STEP4:Y=-S+2*S*Y%/1024.
370 PROCSET(X,Y,Z())
380 PROCSET(.6,0,C())
390 N%=0
400 REPEAT
410 N%+=1
420 PROCRPOWER(Z(),5,A())
430 PROCADD(A(),C(),Z())
440 UNTIL N%=10 OR ABS(Z(0))>10 OR ABS(Z(1))>10 OR FNABS(Z())>10
450 IF ABS(Z(0))<10 OR ABS(Z(1))<10 PLOT69,X%,Y%
460 NEXT
470NEXT
480END
490:
500:
510:
520REM > TSTCMPLX3
530ON ERROR INSTALL "%.COMPLEX":RUN
540PROCINITCOMPLEX
550S=1.2
560ON ERROR OFF
570MODE9
580FORX%=0TO1024STEP4:X=-S+2*S*X%/1024.
590 FORY%=0TO1024STEP4:Y=-S+2*S*Y%/1024.
600 PROCSET(X,Y,Z())
610 PROCSET(.6,0,C())
620 N%=0
630 REPEAT
640 N%+=1
650 PROCPOWER(Z(),Z(),A())
660 PROCRPOWER(Z(),5,B())
670 A()=A()+B()
680 PROCADD(A(),C(),Z())
690 UNTIL N%=10 OR ABS(Z(0))>10 OR ABS(Z(1))>10 OR FNABS(Z())>10
700 IF ABS(Z(0))<10 OR ABS(Z(1))<10 PLOT69,X%,Y%
710 NEXT
720NEXT
730END
740:
750:
760:
770REM > TSTCMPLX4
780ON ERROR INSTALL "%.COMPLEX":RUN
790PROCINITCOMPLEX
800S=2.2
810ON ERROR OFF
820MODE9
830FORX%=0TO1024STEP4:X=-S+2*S*X%/1024.
840 FORY%=0TO1024STEP4:Y=-S+2*S*Y%/1024.
850 PROCSET(X,Y,Z())
860 PROCSET(.5,0,C())
870 N%=0
880 REPEAT
890 N%+=1
900 PROCSIN(Z(),A())
910 PROCRPOWER(Z(),2,B())
920 A()=A()+B()
930 Z()=A()+C()
940 UNTIL N%=10 OR ABS(Z(0))>10 OR ABS(Z(1))>10 OR FNABS(Z())>10
950 IF ABS(Z(0))<10 OR ABS(Z(1))<10 PLOT69,X%,Y%
960 NEXT
970NEXT
980END
990:
1000:
1010:
1020REM > TSTCMPLX5
1030ON ERROR INSTALL "%.COMPLEX":RUN
1040PROCINITCOMPLEX
1050S=3.5
1060ON ERROR OFF
1070MODE9
1080FORX%=0TO1024STEP4:X=-S+2*S*X%/1024.
1090 FORY%=0TO1024STEP4:Y=-S+2*S*Y%/1024.
1100 PROCSET(X,Y,Z())
1110 PROCSET(1,1,C())
1120 N%=0
1130 REPEAT
1140 N%+=1
1150 PROCSIN(Z(),A())
1160 PROCEXP(Z(),B())
1170 A()=A()+B()
1180 Z()=A()+C()
1190 UNTIL N%=10 OR ABS(Z(0))>10 OR ABS(Z(1))>10 OR FNABS(Z())>10
1200 IF ABS(Z(0))<10 OR ABS(Z(1))<10 PLOT69,X%,Y%
1210 NEXT
1220NEXT
1230END
1240:
1250:
1260:
1270REM > TSTCMPLX6
1280ON ERROR INSTALL "%.COMPLEX":RUN
1290PROCINITCOMPLEX
1300S=3.25
1310ON ERROR OFF
1320MODE18
1330FORX%=0TO1024STEP2:X=-S+2*S*X%/1024.
1340 FORY%=0TO1024STEP2:Y=-S+2*S*Y%/1024.
1350 PROCSET(X,Y,Z())
1360 PROCSET(0.5,0,C())
1370 N%=0
1380 REPEAT
1390 N%+=1
1400 PROCSINH(Z(),A())
1410 PROCSIN(Z(),B())
1420 A()=A()+C()
1430 Z()=A()+B()
1440 UNTIL N%=10 OR ABS(Z(0))>10 OR ABS(Z(1))>10 OR FNABS(Z())>10
1450 IF ABS(Z(0))<10 OR ABS(Z(1))<10 PLOT69,X%,Y%
1460 NEXT
1470NEXT
1480END
1490REM-----------------------------------------------------------------------
1500DEFPROCHELP
1510CLS
1520PRINT"THIS LIBRARY PROVIDES THE FOLLOWING PROCEDURES:"'
1530PRINT"U(),V() AND W() DENOTE COMPLEX VARIABLES."
1540PRINT"X AND Y DENOTE REAL VALUES."
1550PRINT"PROCADD( U(),V(),RETURN W()) PROCSUB( U(),V(),RETURN W())"
1560PRINT"PROCMUL( U(),V(),RETURN W()) PROCDIV( U(),V(),RETURN W())"
1570PRINT"PROCRPOWER(U(), X,RETURN W()) PROCPOWER(U(),V(),RETURN W())"
1580PRINT"PROCEXP( U(), RETURN W()) PROCLN( U(), RETURN W())"
1590PRINT"PROCSIN( U(), RETURN W()) PROCCOS( U(), RETURN W())"
1600PRINT"PROCSINH( U(), RETURN W()) PROCCOSH( U(), RETURN W())"
1610PRINT"PROCTAN( U(), RETURN W()) PROCSET( X, Y,RETURN W())"
1620PRINT
1630PRINT"ALSO SUPPLIED ARE THE FOLLOWIG REAL FUNCTIONS:"
1640PRINT"FNSH(X) FNCH(X) FNREAL(Z())"
1650PRINT"FNIMAG(Z()) FNABS(Z()) FNARG(Z())"
1660PRINT'"OF WHICH THE FIRST TWO GIVE THE HYPERBOLIC SINE AND COSINE"
1670PRINT"OF A REAL VALUE."'
1680PRINT"CALL THE PROCEDURE PROCINITCOMPLEX,TO DEFINE THE COMPLEX VARIABLES"
1690PRINT"A() TO Z() AND THE INTERNAL DUMMY'S _A(),_B(),_C(),_A,_B AND _C"
1700PRINT"THE MULTYVALUED ROUTINES GIVE YOU THE PRINCIPAL VALUE ONLY."
1710PRINT'"TESTS HAVE BEEN RUN AGAINST ACORN FORTRAN"
1720PRINT'"6 EXAMPLE PROGRAMS WITH INTERESTING FRACTALS CAN BE FOUND INSIDE THE CODE."
1730PRINT'"YOU CAN SPLIT THEM OFF FOR TESTING, OR"
1740PRINT'"YOU CAN LEAVE THEM THERE,THEY ARE IGNORED."
1750ENDPROC
1760
1770REM-----------------------------------------------------------------------
1780DEFPROCINITCOMPLEX
1790_A=0
1800_B=0
1810_C=0
1820DIM _A(1),_B(1),_C(1)
1830DIM A(1),B(1),C(1),D(1),E(1),F(1),G(1),H(1),I(1),J(1),K(1),L(1),M(1),N(1),O(1),P(1),Q(1),R(1),S(1),T(1),U(1),V(1),W(1),X(1),Y(1),Z(1)
1840ENDPROC
1850REM-----------------------------------------------REAL HYPERBOLIC SINE----
1860DEFFNSH(Y):=(EXPY-EXP(-Y))/2
1870REM-----------------------------------------------REAL HYPERBOLIC COSINE--
1880DEFFNCH(Y):=(EXPY+EXP(-Y))/2
1890REM-----------------------------------------------COMPLEX SINE------------
1900DEFPROCSIN(U(),W())
1910_A(0)=SINU(0)*FNCH(U(1)):_A(1)=COSU(0)*FNSH(U(1)):W()=_A()
1920ENDPROC
1930REM-----------------------------------------------COMPLEX COSINE----------
1940DEFPROCCOS(U(),W())
1950_A(0)=COSU(0)*FNCH(U(1)):_A(1)=-SINU(0)*FNSH(U(1)):W()=_A()
1960ENDPROC
1970REM-----------------------------------------------COMPLEX TANGENT---------
1980DEFPROCTAN(U(),W())
1990PROCSIN(U(),_B())
2000PROCCOS(U(),_C())
2010PROCDIV(_B(),_C(),_A())
2020W()=_A()
2030ENDPROC
2040REM-----------------------------------------------COMPLEX HYPERBOLIC SINE-
2050DEFPROCSINH(U(),W())
2060_A(0)=FNSH(U(0))*COSU(1):_A(1)=FNCH(U(0))*SINU(1):W()=_A()
2070ENDPROC
2080REM-----------------------------------------------COMPLEX HYPERBOLIC COSINE
2090DEFPROCCOSH(U(),W())
2100_A(0)=FNCH(U(0))*COSU(1):_A(1)=FNSH(U(0))*SINU(1):W()=_A()
2110ENDPROC
2120REM-----------------------------------------------COMPLEX MULTIPLICATION--
2130DEFPROCMUL(U(),V(),W())
2140_A(0)=U(0)*V(0)-U(1)*V(1):_A(1)=U(0)*V(1)+U(1)*V(0):W()=_A()
2150ENDPROC
2160:
2170REM-----------------------------------------------COMPLEX DIVISION--------
2180DEFPROCDIV(U(),V(),W()):_A=V(0)*V(0)+V(1)*V(1):_A(0)=(U(0)*V(0)+U(1)*V(1))/_A:_A(1)=(U(1)*V(0)-U(0)*V(1))/_A:W()=_A()
2190ENDPROC
2200REM-----------------------------------------------COMPLEX ADDITION--------
2210DEFPROCADD(U(),V(),W())
2220_A()=U()+V():W()=_A()
2230ENDPROC
2240REM-----------------------------------------------COMPLEX SUBTRACTION-----
2250DEFPROCSUB(U(),V(),W())
2260_A()=U()-V():W()=_A()
2270ENDPROC
2280REM-----------------------------------------COMPLEX TO A REAL(BROKEN) POWER
2290DEFPROCRPOWER(U(),X,W())
2300_C=FNABS(U())^X
2310_B=FNARG(U())*X
2320W(0)=_C*COS_B:W(1)=_C*SIN_B:ENDPROC
2330REM-----------------------------------------E TO A COMPLEX POWER-----------
2340DEFPROCEXP(U(),W())
2350_A=EXP(U(0)):_A(0)=_A*COSU(1):_A(1)=_A*SINU(1):W()=_A()
2360ENDPROC
2370REM-----------------------------------------NATURAL LOG OF A COMPLEX-------
2380DEFPROCLN(U(),W())
2390_A(0)=LN(FNABS(U())):_A(1)=FNARG(U())
2400W()=_A()
2410ENDPROC
2420REM-----------------------------------------COMPLEX TO A COMPLEX POWER-----
2430DEFPROCPOWER(U(),V(),W())
2440PROCLN(U(),_B())
2450PROCMUL(V(),_B(),_B())
2460PROCEXP(_B(),_B())
2470W()=_B()
2480ENDPROC
2490REM-----------------------------------------SET A COMPLEX TO A VALUE-------
2500DEFPROCSET(X,Y,W())
2510W(0)=X
2520W(1)=Y
2530ENDPROC
2540REM-----------------------------------------GET REAL PART OF COMPLEX-------
2550DEFFNREAL(U()):=U(0)
2560REM-----------------------------------------GET IMAGINAIRY PART OF COMPLEX-
2570DEFFNIMAG(U()):=U(1)
2580REM-----------------------------------------GET ABSOLUTE VALUE OF COMPLEX--
2590DEFFNABS(U()):=SQR(U(0)*U(0)+U(1)*U(1))
2600REM-----------------------------------------GET ARGUMENT OF COMPLEX--------
2610DEFFNARG(U())
2620IF U(0)=0 THEN
2630 IF U(1)>0 _A=PI/2 ELSEIF U(1)<0 _A=-PI/2 ELSE _A=0
2640ELSE
2650 _A=ATN(U(1)/U(0))
2660 IFU(0)<0 AND U(1)>=0 _A=_A+PI
2670 IFU(0)<0 AND U(1)<0 _A=_A-PI
2680ENDIF
2690=_A